<template>
	<div class="resource-search-page">
		<!-- 学院项目树  audit-state="W"-->
		<div class="left-tree">
			<tree-project
				ref="projectTreeRef"
				:default-checked="true"
				menu-code="rc/courseware/audit/wait-list"
				audit-state="W"
				@ready="onChooseProject"
				@choose="onChooseProject"
			/>
		</div>
		<!-- 搜索组件 和 列表 -->
		<div class="resource-serach">
			<!-- 快速搜索区域 -->
			<div class="serach-resource-option" v-loading="isShowLoading_quick">
				<quick-screen
					ref="quickScreenRef"
					:quick-list="quickList"
					:project-id="projectId"
					@get-children-data="getChildrenData"
				/>
			</div>
			<div class="serach-resource-filtrate mar-b16">
				<ve-filtrate
					ref="veFiltrate"
					:advanced="true"
					:filtrates="filtrate"
					:search-loading="isShowLoading_table"
					:def-submit="false"
					@submit="onSubmit"
				/>
			</div>
			<!-- 资源列表 -->
			<div class="resource-table" v-loading="isShowLoading_table">
				<div class="resource-table-option flex ai-center" v-permiss-code="'rc/courseware/audit/wait-audit'">
					<el-checkbox
						label="全选"
						v-model="isCheckedAll"
						@change="oncheckallchange"
					/>
					<el-button
						class="mar-l16"
						size="medium"
						:class="[{'theme_font_color': selectItems.length},{'theme-border-color': selectItems.length}]"
						@click="onBatchAudit"
						:loading="isShowBatchAuditLoading"
					>
						批量审核
					</el-button>
				</div>
				<el-table
					class="resource-table-list"
					ref="table"
					stripe
					:data="resourceList"
					:show-header="false"
					@select="selectionChange"
				>
					<el-table-column
						type="selection"
						width="45"
						v-if="PermissUtil.checkPermiss('rc/courseware/audit/wait-delete')"
					/>
					<el-table-column prop="">
						<template #default="{ row}">
							<div class="resource-table-list-item flex ai-center">
								<img class="icon-resource" src="@rc/assets/images/icon-resource.png" alt="">
								<div class="resource-info">
									<div class="flex  flex-between ai-center">
										<el-popover
											placement="top-start"
											trigger="hover"
											width="600"
											popper-class="course-ware-popper"
											:content="row.name"
										>
											<div slot="reference" class="resource-info-name text-overflow-1 mar-r16">
												{{ row.name }}
											</div>
										</el-popover>
										<div class="resource-option-btn">
											<el-button
												v-for="permiss in permissArr.filter((p,index)=>(index<=2))"
												:key="permiss.permiss"
												type="text"
												class="button-text"
												@click.native="handleClick(permiss.eventName,row)"
											>
												{{ permiss.name }}
											</el-button>
											<el-dropdown>
												<span class="el-dropdown-link">
													<el-button
														type="text"
														class="button-text"
														v-show="permissArr.length>3"
													> 更多</el-button>
												</span>
												<el-dropdown-menu slot="dropdown">
													<el-dropdown-item
														v-for="permiss in permissArr.filter((p,index)=>(index>2))"
														:key="permiss.permiss"
														@click.native="handleClick(permiss.eventName,row)"
													>
														{{ permiss.name }}
													</el-dropdown-item>
												</el-dropdown-menu>
											</el-dropdown>
										</div>
									</div>
									<div class="resource-info-bottom flex ai-center">
										<div class="resource-info-text">授课老师：{{ row.professorName ||'-' }}</div>
										<div class="resource-info-text">上传人：{{ row.createUserName ||'-' }}</div>
										<div class="resource-info-text">上传时间：{{ row.createTime ||'-' }}</div>
										<div class="resource-info-text flex ai-center">
											<span>文件名称：</span>
											<div class="vid-num text-overflow-1">{{ row.sourceFileName ||'-' }}</div>
										</div>
										<div class="resource-info-text">时长：{{ row.duration | getHMS }}</div>
									</div>
								</div>
							</div>
						</template>
					</el-table-column>
				</el-table>
				<ve-pagination
					:get-page="onSearchResource"
					:page.sync="resourceQueryPagination"
				/>
			</div>
		</div>
		<!-- 弹窗开始-->
		<!-- 删除课件 -->
		<delete-resource
			:is-show.sync="dialog.isShowDeleteDialog"
			:is-show-resource-tip="dialog.isShowDeleteDialogResourceTip"
			:is-show-card-tip="dialog.isShowDeleteDialogCardTip"
			:resource-id="resourceId"
			:page-index="resourceQueryPagination.pageIndex"
			@close="closedeleteDialog"
		/>
		<!-- 替换课件弹窗 -->
		<replace-courseware
			:is-show.sync="dialog.isShowReplaceDialog"
			:resource-id="resourceId"
			@close="closeReplaceDialog"
			@replace="onSubmit"
		/>
		<!-- 操作日志弹窗 -->
		<operation-log
			:is-show.sync="dialog.isShowLogDialog"
			:resource-id="resourceId"
			@close="closeLogDialog"
		/>
		<audit-resource
			:is-show.sync="dialog.isShowAuditDialog"
			:resource-id="resourceId"
			:resource-ids="resourceIds"
			:type="auditType"
			@close="closeAuditDialog"
			@success="onSubmit"
			@next-audit="onNextResourceAudit"
		/>
		<!-- 课件编辑弹窗 -->
		<edit-mixin-edit-dialog v-if="editMixin_isShowEditDialog" :visibly.sync="editMixin_isShowEditDialog">
			<!-- 基础信息 -->
			<edit-mixin-edit-base
				v-loading="editMixin_baseLoading"
				:default-data="editMixin_editBaseInfo"
				@submit="editMixin_baseEditSubmit"
			/>
			<!-- 项目信息 -->
			<edit-mixin-edit-project
				v-loading="editMixin_projectLoading"
				style="margin-top:8px"
				:is-show-relevance="true"
				:not-edit-main="true"
				:default-data="editMixin_editProjectInfo"
				@submit="editMixin_projectEditSubmit"
				@delete="editMixin_projectEditDelete"
			/>
			<edit-mixin-edit-other-message
				style="margin-top:8px"
				v-loading="editMixin_otherLoading"
				:default-data="editMixin_editOtherInfo"
				@submit="editMixin_otherEditSubmit"
			/>
			<template #footer>
				<div class="dialog-footer-box">
					<el-button @click="editMixin_isShowEditDialog = false">关 闭</el-button>
					<el-button
						type="primary"
						:loading="editMixin_AuditLoading"
						@click="handleAudit(editMixin_editInfo.resourceId,true)"
					>
						审核通过
					</el-button>
				</div>
			</template>
		</edit-mixin-edit-dialog>
		<!-- 弹窗结束 -->
	</div>
</template>

<script src="./index.mjs"/>
<style lang="less" scoped src="../../style/search-page.less"></style>
<style lang="less" src="../../style/search-pages-global.less"/>
